package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.base.BaseDAO;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.AdminDAO;
import com.atguigu.entity.Admin;
import com.atguigu.service.AdminService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @PACKAGE_NAME: com.atguigu.service.impl
 * @CLASSNAME: AdminServiceImpl
 * @AUTHOR: zhangsan
 * @DATE: 2024/4/17 9:00
 * @SINCE 17.0.7
 * @DESCRIPTION: AdminServiceImpl 后台管理员业务层
 */
@Service(interfaceClass = AdminService.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class AdminServiceImpl extends BaseServiceImpl<Admin> implements AdminService {
    @Resource
    private AdminDAO adminDAO;

    @Override
    protected BaseDAO<Admin> getEntityDAO() {
        return adminDAO;
    }

    /**
     * 查询所有管理员
     * @return
     */
    @Override
    public List<Admin> findAll() {
        List<Admin> adminList =  adminDAO.findAll();
        return adminList;
    }

    /**
     * 通过用户名查询Admin
     *
     * @param username
     * @return
     */
    @Override
    public Admin getByUsername(String username) {
        Admin admin = adminDAO.getByUsername(username);
        return admin;
    }
}
